package com.auxgroup.hr.front.site.co.personnel;

import java.math.BigDecimal;
import java.util.List;

import javax.annotation.Resource;

import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.auxgroup.hr.front.commons.vo.BaseResponseVO;
import com.auxgroup.hr.front.dao.domain.PsCBankacctPrimary;
import com.auxgroup.hr.front.dao.domain.PsPyeBankacct;
import com.auxgroup.hr.front.dozer.IObjectMapper;
import com.auxgroup.hr.front.service.personnal.PyeBankacctService;
import com.auxgroup.hr.front.site.co.BaseCO;

/**
 * 银行账号CO
 * 
 * @author wangchangyun
 * @version 创建时间：180523
 */
@RestController
@RequestMapping("${auxgroup.hr.contextPath}/pyeBankacct")
public class PyeBankacctCO extends BaseCO {

	private static final Logger logger = LoggerFactory.getLogger(PyeBankacctCO.class);

	@Autowired
	public PyeBankacctService pyeBankacctService;

	@Resource(name = "dozerMapper")
	protected IObjectMapper objectMapper;

	/**
	 * 获取银行账号
	 * 
	 * @param hireId
	 * @return
	 */
	@GetMapping(value = "/getOne")
	public BaseResponseVO getOne(String emplid) {
		logger.info("getPyeBankacct param= {}", emplid);
		PsCBankacctPrimary bankacctInfo = new PsCBankacctPrimary();
		bankacctInfo.setEmplid(emplid);
		bankacctInfo.setAccountId(new BigDecimal("1"));//默认1
		PsPyeBankacct pyeBankacct = pyeBankacctService.getPyeBankacct(bankacctInfo);
		return buildRespone(pyeBankacct);
	}
	
	/**
	 * 获取全部
	 * 
	 * @param rsHireId
	 * @return
	 */
	@GetMapping(value = "/getAll")
	public BaseResponseVO getAll(String emplid) {
		List<PsPyeBankacct> list = pyeBankacctService.getAll();
		return buildRespone(list);
	}

	

	/**
	 * 保存银行账号
	 * 
	 * @param hireId
	 * @return
	 */
	@PostMapping(value = "/save")
	public BaseResponseVO save(PsPyeBankacct pyeBankacct) {
		logger.info("savePyeBankacct param= {}", pyeBankacct);
		pyeBankacct = pyeBankacctService.save(pyeBankacct);
		if (StringUtils.isNotBlank(pyeBankacct.getEmplid())) {
			return buildRespone(true);
		}
		return buildRespone(false);

	}

}
